package com.dl.study.module.base.resinfo.controller;

import com.dl.study.base.PageResultDTO;
import com.dl.study.util.resp.ResponseDTO;
import com.dl.study.module.base.resinfo.domain.dto.ResInfoDTO;
import com.dl.study.module.base.resinfo.domain.dto.ResInfoQueryDTO;
import com.dl.study.module.base.resinfo.domain.dto.ResInfoListQueryDTO;
import com.dl.study.module.base.resinfo.domain.vo.ResInfoAddVO;
import com.dl.study.module.base.resinfo.domain.vo.ResInfoUpdateVO;
import com.dl.study.module.base.resinfo.service.ResInfoService;
import com.dl.study.util.BeanCopyUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * [ 系统资源表 ]
 *
 * @author dl
 * @version 1.0
 * @company xxxx
 * @copyright (c) 2019 xxxxInc. All rights reserved.
 * @date 2021-10-28 16:26:17
 * @since JDK1.8
 */
@RestController
@Api(tags = {"系统资源表" })
public class ResInfoController {

    @Autowired
    private ResInfoService resInfoService;

    @ApiOperation(value = "分页查询系统资源表", notes = "@author dl")
    @PostMapping("/resInfo/page/query")
    public ResponseDTO<PageResultDTO<ResInfoDTO>> queryByPage(@RequestBody ResInfoQueryDTO queryDTO) {
        return resInfoService.queryByPage(queryDTO);
    }

    @ApiOperation(value = "根据条件查询系统资源表", notes = "@author dl")
    @PostMapping("/resInfo/list/query")
    public ResponseDTO<List<ResInfoDTO>> queryListByCondition(@RequestBody ResInfoListQueryDTO listQueryDTO) {
        return resInfoService.queryListByCondition(listQueryDTO);
    }

    @ApiOperation(value = "添加系统资源表", notes = "@author dl")
    @PostMapping("/resInfo/add")
    public ResponseDTO<String> add(@RequestBody @Valid ResInfoAddVO addVO) {
        ResInfoDTO dto = BeanCopyUtil.copy(addVO, ResInfoDTO.class);
        return resInfoService.add(dto);
    }

    @ApiOperation(value = "修改系统资源表", notes = "@author dl")
    @PostMapping("/resInfo/update")
    public ResponseDTO<String> update(@RequestBody @Valid ResInfoUpdateVO updateVO) {
        ResInfoDTO dto = BeanCopyUtil.copy(updateVO, ResInfoDTO.class);
        return resInfoService.update(dto);
    }


    @ApiOperation(value = "删除系统资源表", notes = "@author dl")
    @GetMapping("/resInfo/delete/{id}")
    public ResponseDTO<String> delete(@PathVariable("id") Long id) {
        return resInfoService.delete(id);
    }


    @ApiOperation(value = "详情系统资源表", notes = "@author dl")
    @GetMapping("/resInfo/detail/{id}")
    public ResponseDTO<ResInfoDTO> detail(@PathVariable("id") Long id) {
        return resInfoService.detail(id);
    }


    @ApiOperation(value = "批量删除系统资源表", notes = "@author dl")
    @PostMapping("/resInfo/deleteByIds")
    public ResponseDTO<String> deleteByIds(@RequestBody @Valid List<Long> ids) {
        return resInfoService.deleteByIds(ids);
    }


    @ApiOperation(value = "批量添加系统资源表", notes = "@author dl")
    @PostMapping("/resInfo/addList")
    public ResponseDTO<String> addList(@RequestBody @Valid List<ResInfoDTO> addList) {
        return resInfoService.addList(addList);
    }
}
